<template>
    <a-row :gutter="10">
      <a-col :md="leftColMd" :sm="24">
        <a-card :bordered="false">
          <yks-equipment-list ref="equipmentList" @openSubMenu="openSubMenu" @openMainMenu="openMainMenu"/>
        </a-card>
      </a-col>
      <a-col :md="rightColMd" :sm="24">
        <a-card :bordered="false">
          <div style="text-align: right;margin-bottom: -20px;z-index: 1;position:relative">
            <a-tooltip placement="top" title="返回项目列表">
                <a-icon type="close-circle" @click="openMainMenu" />
            </a-tooltip>
          </div>
          <a-tabs defaultActiveKey="1"  @change="callback">
            <!-- <a-tab-pane tab="项目基本信息" v-if="hasbaseInfoPermission" key="1" forceRender>
              <equipment-base-info v-if="hasbaseInfoPermission" ref="baseInfo" />
            </a-tab-pane> -->
            
            <a-tab-pane tab="实时动态运行图" v-if="hasequimentfuxaDynamicRunPermission" key="3" forceRender>
              <yks-equipment-fuxa ref="equimentfuxaDynamicRun" v-if="hasequimentfuxaDynamicRunPermission" :disabled="true"></yks-equipment-fuxa>      
            </a-tab-pane>
            <a-tab-pane tab="工艺运行曲线图" key="6" v-if="hasequimentfuxaGraphPermission" forceRender>
              <yks-equipment-fuxa ref="equimentfuxaGraph" v-if="hasequimentfuxaGraphPermission" :disabled="true"></yks-equipment-fuxa>        
            </a-tab-pane>
            <a-tab-pane tab="工艺运行数据报表" key="5" v-if="hasrunDataQueryPermission" forceRender>
              <yks-equipment-rundata-list ref="runDataQuery" v-if="hasequipmentRundataPermission" :disabled="true"></yks-equipment-rundata-list>
              <!-- <YksEquipmentRunDataReport ref="runDataQuery" v-if="hasrunDataQueryPermission" :disabled="true"></YksEquipmentRunDataReport> -->
              <!-- <j-onl-query-list ref="runDataQuery" code="runDataQuery" v-if="hasrunDataQueryPermission" :param="{equipment_id:currentEquipmentId}" field="name" orgFields="name" destFields="name" :multi="true"/> -->
                <!-- <yks-equipment-form ref="equimentinfo" :disabled="true"></yks-equipment-form>            -->
            </a-tab-pane>
            <a-tab-pane tab="运行数据后台管理" v-if="hasequipmentRundataPermission" key="4" forceRender>  
              <YksEquipmentRundata ref="equipmentRundata" v-if="hasequipmentRundataPermission" :disabled="true"></YksEquipmentRundata>
              <!-- <yks-equipment-rundata-list ref="equipmentRundata" v-if="hasequipmentRundataPermission" :disabled="true"></yks-equipment-rundata-list> -->
              <!-- <j-onl-query-list ref="runDataQuery" code="runDataQuery" field="name" orgFields="name" destFields="name" :multi="true"/>  -->
                <!-- <yks-equipment-form ref="equimentinfo" :disabled="true"></yks-equipment-form>    -->
            </a-tab-pane>
            
           
            <a-tab-pane tab="项目监控" v-if="hasvideoPermission" key="2" forceRender>
                <!-- <yks-equipment-fuxa ref="equimentFuxaProductionDrawing" :disabled="true"></yks-equipment-fuxa> -->
            </a-tab-pane>
            <a-tab-pane tab="项目资料" key="7" v-if="haseequimentdocumentPermission" forceRender>
                <yks-equipment-document-list ref="equimentdocument"  v-if="haseequimentdocumentPermission" :disabled="true"></yks-equipment-document-list>        
            </a-tab-pane>
          </a-tabs>
          
        </a-card>
      </a-col>
    </a-row>
</template>
  <script>
    import DeptBaseInfo from '@/views/system/modules/DeptBaseInfo'
    import DeptUserInfo from '@/views/system/modules/DeptUserInfo'
    import { queryMyDepartTreeList, searchByKeywords } from '@/api/api'
    // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import DeptRoleInfo from '@/views/system/modules/DeptRoleInfo'
    import YksEquipmentList from './YksEquipmentList.vue'
    import YksEquipmentManageUsersList from '../mng/YksEquipmentManageUsersList.vue'
    import YksEquipmentConfigurationPlcList from './YksEquipmentConfigurationPlcList'
    import YksEquipmentConfigurationPartList from './YksEquipmentConfigurationPartList.vue'
    import DevEquipmentConfigProductList from './DevEquipmentConfigProductList.vue'
import YksEquipmentForm from './modules/YksEquipmentForm.vue'
import YksEquipmentFuxa from './YksEquipmentFuxa.vue'
import YksEquipmentDocumentList from './YksEquipmentDocumentList.vue'
import JOnlQueryList from '../../../components/jeecg/JOnlQueryList.vue'
import EquipmentBaseInfo from './modules/EquipmentBaseInfo.vue'
import YksEquipmentRundataList from '../mng/YksEquipmentRundataList.vue'
import { USER_INFO, USER_INFO_PRO,USER_AUTH, SYS_BUTTON_AUTH } from '@/store/mutation-types'
import YksEquipmentRundata from '../mng/YksEquipmentRundata.vue'
import YksEquipmentRunDataReport from '../mng/YksEquipmentRunDataReport.vue'
  
    export default {
      name: 'DepartUserList',
      mixins: [],
      components: {
    DeptRoleInfo,
    DeptBaseInfo,
    DeptUserInfo,
    YksEquipmentList,
    YksEquipmentManageUsersList,
    YksEquipmentConfigurationPlcList,
    YksEquipmentConfigurationPartList,
    DevEquipmentConfigProductList,
    YksEquipmentForm,
    YksEquipmentFuxa,
    YksEquipmentDocumentList,
    JOnlQueryList,
    EquipmentBaseInfo,
    YksEquipmentRundataList,
    YksEquipmentRundata,
    YksEquipmentRunDataReport
},
      data() {
        return {
          rightColMd : 0,
          leftColMd : 24,
          currentDeptId: '',
          currentEquipmentId : '',
          model: {},
          checkedKeys: [],
          selectedKeys: [],
          currFlowId : '',
          currFlowName : '',
          labelCol: {
            xs: {span: 24},
            sm: {span: 5}
          },
          wrapperCol: {
            xs: {span: 24},
            sm: {span: 16}
          },
          params:{},
          hasbaseInfoPermission:true,
          hasvideoPermission:true,
          hasequimentfuxaDynamicRunPermission:true,
          hasequipmentRundataPermission:true,
          hasrunDataQueryPermission:true,
          hasequimentfuxaGraphPermission:true,
          haseequimentdocumentPermission:true,

        }
      },
      methods: {
        preCheckPermission() {
      this.hasbaseInfoPermission=false
      this.hasvideoPermission=false
      this.hasequimentfuxaDynamicRunPermission=false
      this.hasequipmentRundataPermission=false
      this.hasrunDataQueryPermission=false
      this.hasequimentfuxaGraphPermission=false
      this.haseequimentdocumentPermission=false
      let permissions = sessionStorage.getItem(USER_AUTH)
      if (permissions) {
        permissions = JSON.parse(permissions)
        permissions.forEach((v, k) => 
        {
          if (v.action == 'hasbaseInfoPermission') {
            this.hasbaseInfoPermission = true
          }
          if (v.action == 'hasvideoPermission') {
            this.hasvideoPermission = true
          }
          if (v.action == 'hasequimentfuxaDynamicRunPermission') {
            this.hasequimentfuxaDynamicRunPermission = true
          }
          if (v.action == 'hasequipmentRundataPermission') {
            this.hasequipmentRundataPermission = true
          }
          if (v.action == 'hasrunDataQueryPermission') {
            this.hasrunDataQueryPermission = true
          }
          if (v.action == 'hasequimentfuxaGraphPermission') {
            this.hasequimentfuxaGraphPermission = true
          }
          if (v.action == 'haseequimentdocumentPermission') {
            this.haseequimentdocumentPermission = true
          }
        })
      }
      
    },
        openSubMenu(record){      
          debugger   
          this.preCheckPermission()
           this.rightColMd = 24
           this.leftColMd = 0
           this.currentEquipmentId = record.id
           this.params={equipment_id:this.currentEquipmentId}
           if(this.hasrunDataQueryPermission){
            // this.$refs.runDataQuery.openModal()
            debugger
            this.$refs.runDataQuery.open(record)
           }
            
          //  if(this.hasbaseInfoPermission){
          //   this.$refs.baseInfo.open(record)
          //  }
           if(this.hasequimentfuxaDynamicRunPermission){
            this.$refs.equimentfuxaDynamicRun.open(record)
            this.$refs.equimentfuxaDynamicRun.fuxaTpye='DynamicRun'
           }
           if(this.hasequimentfuxaGraphPermission){
            this.$refs.equimentfuxaGraph.open(record)
           this.$refs.equimentfuxaGraph.fuxaTpye='Graph'
           }
           if(this.hasequipmentRundataPermission){
            this.$refs.equipmentRundata.open(record)
           }
           if(this.haseequimentdocumentPermission){
            this.$refs.equimentdocument.open(record)
           }
           console.log(record)
        },
        openMainMenu() {
           this.rightColMd = 0
           this.leftColMd = 24
        },
        callback(key) {
          debugger
          if(key=='5')
          {
            if(this.hasrunDataQueryPermission){
            this.$refs.runDataQuery.open(record)
           }
          }
        },
        clearSelectedDepartKeys() {
          this.checkedKeys = [];
          this.selectedKeys = [];
          this.currentDeptId = '';
          this.$refs.DeptUserInfo.currentDeptId='';
          this.$refs.DeptRoleInfo.currentDeptId='';
        },
  
      },
      created() {
        this.currFlowId = this.$route.params.id
        this.currFlowName = this.$route.params.name
        // this.loadTree()
      },
    }
  </script>
  <style scoped>
    @import '~@assets/less/common.less'
  </style>